package com.zhaopin.json;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.google.gson.Gson;
import com.jayway.jsonpath.JsonPath;
import org.junit.Assert;
import org.junit.Test;

public class My {
    @Test
    public void getByPathTest(){
        String jsonStr = "{\n" +
                "    \"responseHeader\":\n" +
                "    {\n" +
                "        \"zkConnected\": true,\n" +
                "        \"status\": 0,\n" +
                "        \"QTime\": 8,\n" +
                "        \"params\":\n" +
                "        {\n" +
                "            \"q\": \"CV_CUR_LIVE_STREET:[* TO *]\",\n" +
                "            \"fl\": \"ID,CV_CUR_LIVE_STREET,CV_USERID\",\n" +
                "            \"start\": \"1\",\n" +
                "            \"fq\": \"_parent_:true\",\n" +
                "            \"sort\": \"CV_ACTIVE_TIME_LAST desc\",\n" +
                "            \"rows\": \"100\"\n" +
                "        }\n" +
                "    },\n" +
                "    \"response\":\n" +
                "    {\n" +
                "        \"numFound\": 5,\n" +
                "        \"start\": 1,\n" +
                "        \"numFoundExact\": true,\n" +
                "        \"docs\":\n" +
                "        [\n" +
                "            {\n" +
                "                \"ID\": \"JI704881999R90500000000_1\",\n" +
                "                \"CV_USERID\": 1070488199,\n" +
                "                \"CV_CUR_LIVE_STREET\":\n" +
                "                [\n" +
                "                    \"530\",\n" +
                "                    \"2001\",\n" +
                "                    {\n" +
                "                        \"age\":\n" +
                "                        [\n" +
                "                            \"1\",\n" +
                "                            \"2\",\n" +
                "                            \"3\"\n" +
                "                        ]\n" +
                "                    }\n" +
                "                ]\n" +
                "            },\n" +
                "            {\n" +
                "                \"ID\": \"JH380570242R90500000000_1\",\n" +
                "                \"CV_USERID\": 1138057024,\n" +
                "                \"CV_CUR_LIVE_STREET\":\n" +
                "                [\n" +
                "                    \"530\",\n" +
                "                    \"2006\",\n" +
                "                    {\n" +
                "                        \"age\":\n" +
                "                        [\n" +
                "                            \"4\",\n" +
                "                            \"5\",\n" +
                "                            \"6\"\n" +
                "                        ]\n" +
                "                    }\n" +
                "                ]\n" +
                "            },\n" +
                "            {\n" +
                "                \"ID\": \"JH393366872R90500000000_1\",\n" +
                "                \"CV_USERID\": 1139336687,\n" +
                "                \"CV_CUR_LIVE_STREET\":\n" +
                "                [\n" +
                "                    \"530\",\n" +
                "                    \"2006\",\n" +
                "                    {\n" +
                "                        \"age\":\n" +
                "                        [\n" +
                "                            \"7\",\n" +
                "                            \"8\",\n" +
                "                            \"9\"\n" +
                "                        ]\n" +
                "                    }\n" +
                "                ]\n" +
                "            },\n" +
                "            {\n" +
                "                \"ID\": \"JH126004167R90500000000_1\",\n" +
                "                \"CV_USERID\": 1112600416,\n" +
                "                \"CV_CUR_LIVE_STREET\":\n" +
                "                [\n" +
                "                    \"555\",\n" +
                "                    \"850\",\n" +
                "                    \"4897\",\n" +
                "                    {\n" +
                "                        \"age\":\n" +
                "                        [\n" +
                "                            \"10\",\n" +
                "                            \"11\",\n" +
                "                            \"12\"\n" +
                "                        ]\n" +
                "                    }\n" +
                "                ]\n" +
                "            }\n" +
                "        ]\n" +
                "    }\n" +
                "}";

        Object read = JsonPath.read(jsonStr, "response.docs[*].CV_CUR_LIVE_STREET[*].age");
        System.out.println(read);

    }
}
